package com.eascs.finance.admin.web.controller;

import com.eascs.web.sso.UserHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.app.dao.PageResult;
import com.eascs.common.util.UrlUtil;
import com.eascs.finance.admin.common.controller.BaseMasterViewController;
import com.eascs.fp.common.dto.MemberDTO;
import com.eascs.fp.common.vo.ModelResult;
import com.eascs.fp.uc.IMemberService;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.view.BaseRestResult;
import com.eascs.site.view.ViewContext;
import com.eascs.tag.MenuTag;
import com.eascs.web.context.RequestContext;

@Controller
@RequestMapping("/user")
public class UserController extends BaseMasterViewController {
	
	@Reference
	IMemberService memberService;

	@Override
	public void preHandle() {
		super.preHandle();
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "userManage");
	}
	
	@RequestMapping(value="/index")
	public String index(MemberDTO vo){
		vo.setPageSize(10);
		 ModelResult<PageResult<Object[]>> page= memberService.queryMemberPage(vo);
		 PageResult<Object[]> pageResult=new PageResult<Object[]>();
		 if(page.isSuccess()){
			 pageResult=page.getModel();
		 }
	  
        String[] titles = {"手机号", "注册时间","申贷记录"};
      
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles);
		paginationInfo.setUrl(UrlUtil.resetParam(RequestContext.getRequestUrlWithQueryString(), "pageIndex", ""));
		paginationInfo.setBuildPagingNavigation(true);
		paginationInfo.setFirstRenderColumnIndex(1);
		ViewContext.put("paginationInfo", paginationInfo);
		ViewContext.put("vo", vo);
		BaseRestResult.refresh();
		return "/user/index";
		
		
	}

	@RequestMapping(value="/noauth")
	public String noauth(MemberDTO vo){
		ViewContext.put("vo", UserHolder.getUser().getAccount());
		BaseRestResult.refresh();
		return "/notauthView";
	}
	
	
}
